/******************************************************************/
/*                                                                */
/*  Winpooch : Windows Watchdog                                   */
/*  Copyright (C) 2004-2005  Benoit Blanchon                      */
/*                                                                */
/*  This program is free software; you can redistribute it        */
/*  and/or modify it under the terms of the GNU General Public    */
/*  License as published by the Free Software Foundation; either  */
/*  version 2 of the License, or (at your option) any later       */
/*  version.                                                      */
/*                                                                */
/*  This program is distributed in the hope that it will be       */
/*  useful, but WITHOUT ANY WARRANTY; without even the implied    */
/*  warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR       */
/*  PURPOSE.  See the GNU General Public License for more         */
/*  details.                                                      */
/*                                                                */
/*  You should have received a copy of the GNU General Public     */
/*  License along with this program; if not, write to the Free    */
/*  Software Foundation, Inc.,                                    */
/*  675 Mass Ave, Cambridge, MA 02139, USA.                       */
/*                                                                */
/******************************************************************/

#ifndef _SPYDLL_H
#define _SPYDLL_H

#ifdef SPYDLL_BUILD_DLL
#define IMPEXP __declspec(dllexport)
#else
#define IMPEXP __declspec(dllimport)
#endif

#include <windows.h>

#include "Condition.h"


// Naming convention :
// - SDN_ = Spy Dll Notification, used for codes
// - SDN  = Spy Dll Notification Message, used for structures

#define SDN_CATCH_CALL		1
#define SDN_CREATING_PROCESS	3
#define SDN_PROCESS_CREATED	4
#define SDN_CREATING_FAILED	5
#define SDN_NEW_REGISTRY_KEY	6
#define SDN_KEY_POOL_HIWAT	7 // high water level reach
#define SDN_KEY_POOL_LOWAT	8 // low water level reach

typedef struct {
  DWORD		dwCode ;
  DWORD		dwProcessId ;
} SDNMHDR ;

typedef struct {
  SDNMHDR	hdr ;
  CONDITION	cond ;
} SDNCATCHCALL ;

typedef struct {
  SDNMHDR	hdr ;
  TCHAR		szPath[MAX_PATH] ;
} SDNCREATINGPROCESS ;

typedef struct {
  SDNMHDR	hdr ;
  DWORD		dwProcessId ;
  BOOL		bHooked ;
  TCHAR		szPath[MAX_PATH] ;
} SDNPROCESSCREATED ;

typedef struct {
  SDNMHDR	hdr ;
  TCHAR		szKey[MAX_PATH] ;
} SDNNEWREGKEY ;

typedef DWORD WINAPI (*SPYDLL_NOTIFYPROC)(SDNMHDR*) ;



IMPEXP void SpyDll_Init (DWORD dwServerProcessID,
			 SPYDLL_NOTIFYPROC pfnNotifyProc) ;

IMPEXP void SpyDll_Uninit () ;

IMPEXP BOOL SpyDll_InjectInProcess (DWORD dwProcessId) ;

IMPEXP BOOL SpyDll_InjectInSuspendedThread (HANDLE hProcess, HANDLE hThread) ;

IMPEXP HINSTANCE SpyDll_IsProcessInjected (DWORD dwProcessId,
					   LPCTSTR szDllFileName) ;

IMPEXP BOOL SpyDll_EjectFromProcess (DWORD dwProcessId, HINSTANCE hSpyDllInst) ;


#endif
